<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.min.js"></script>
</head>

<body>
    <div id="app">
        <h2 id="msg">{{message}}</h2>
    </div>
</body>
<script>
    var VM = new Vue({
        el: '#app',
        data: {
            message: '卢本伟牛逼！',
        },
        methods: {
            show: function() {
                alert("show方法执行了");
            }
        },
        beforeCreate() {
            alert("1.beforeCreate函数,在Vue对象实例化之前执行");
            console.log(this.message);
            this.show();
        },
        created() {
            alert("2.created函数执行时,组件的实例化完成,但是DOM页面还未生成");
            console.log("2", this.message);
            this.show();
        },
        beforeMount() {
            alert(
                "3.beforeMount函数执行时,模板已经在内存中编辑完成了,但是还没有被渲染到页面中"
            );
            console.log(
                "页面显示的内容" + document.getElementById("msg").innerText
            );
            console.log("data中的数据: " + this.message);
        },
    })
</script>

</html>